package com.example.administrator.about_huanxin.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.about_huanxin.R;


/**
 * Created by Administrator on 2017/3/10.
 */
public abstract class BaseFragment extends Fragment {

    public  TextView title_tv;
    public  Button title_btn;
    private FrameLayout base_container;
    private TextView empty_tv;
    private LinearLayout base_fra_ll;
    private LayoutInflater inflater;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.inflater = inflater;
        return inflater.inflate(R.layout.fragment_base,null);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        title_tv = (TextView) view.findViewById(R.id.title_tv);
        title_btn = (Button) view.findViewById(R.id.title_btn);
        base_container = (FrameLayout) view.findViewById(R.id.base_container);
        empty_tv = (TextView) view.findViewById(R.id.empty_tv);
        base_fra_ll = (LinearLayout) view.findViewById(R.id.base_fra_ll);
        setEmptyView(empty_tv,true);
        setTitleText(title_tv);
        setTitleButton(title_btn);
        setVisibleTitle(base_fra_ll);
        View contentview = setContainer(LayoutInflater.from(getActivity()),base_container);
        initContent(contentview);
    }

    protected void setVisibleTitle(LinearLayout ll){
        base_fra_ll.setVisibility(View.VISIBLE);
    }

    public abstract void setEmptyView(TextView tv,boolean isVisible);

    public abstract void setTitleText(TextView tv);

    public abstract void setTitleButton(Button btn);

    public abstract View setContainer(LayoutInflater inflater,FrameLayout fram);

    public abstract void initContent(View content);
}
